package mvc.handlers;

import mvc.framework.*;

/**
 * Handler per gestire l'azione di logout al sistema
 * 
 * @author Grillo
 */
public class LogoutHandler extends AbsRequestHandler {

    private final static String ACTION_NAME = "logout";

    public LogoutHandler(DialogHandler dHandler) {
        super(dHandler);
    }

    public String getActionName() {
        return ACTION_NAME;
    }

    public void setNextPage() {
        nextPage = "/views/home.jsp";
    }
    
    public int validate() {
        return SUCCESS;
    }

    public int execute() {
        SessionManager.removeAttribute(dialogHandler.getSession(), "tipo_utente");
        SessionManager.removeAttribute(dialogHandler.getSession(), "utente");
        return SUCCESS;
    }

    @Override
    public IRequestHandler clone(DialogHandler dHandler) throws CloneNotSupportedException {
        return new LogoutHandler(dHandler);
    } 
}